<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>																			
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>																																			
<html lang="en">																																											
<body class="wysihtml5-supported">																																							
	<div id="content">																																										
		<div class="container-fluid">																																							
			<div class="row-fluid">																																							
				<div class="span6">																																							
					<div class="widget-box">																																					
						<div class="widget-title">																																			
							<h5>表单</h5>																																							
						</div>																																									
						<div class="widget-content nopadding">																																
							<form id="employeeForm" action="" method="post" class="form-horizontal">																					
								<div class="control-group">																																
									<label class="control-label">员工编号 :</label>																									
									<div class="controls">																																
										<input  primaryKey="true" type="text" class="span11" name="id" placeholder="">		
										<span class="error_msg" name="error_id"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">员工姓名 :</label>																									
									<div class="controls">																																
										<input  type="text" class="span11" name="empName" placeholder="">		
										<span class="error_msg" name="error_empName"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">职位 :</label>																									
									<div class="controls">																																
										<input  type="text" class="span11" name="job" placeholder="">		
										<span class="error_msg" name="error_job"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">出生日期 :</label>																									
									<div class="controls">																																
										<input  type="date" class="span11" name="birthday" placeholder="">		
										<span class="error_msg" name="error_birthday"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">主管编号 :</label>																									
									<div class="controls">																																
										<input  type="text" class="span11" name="mgr" placeholder="">		
										<span class="error_msg" name="error_mgr"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">录用日期 :</label>																									
									<div class="controls">																																
										<input  type="date" class="span11" name="hiredata" placeholder="">		
										<span class="error_msg" name="error_hiredata"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">薪水 :</label>																									
									<div class="controls">																																
										<input  type="text" class="span11" name="salary" placeholder="">		
										<span class="error_msg" name="error_salary"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">部门编号 :</label>																									
									<div class="controls">																																
										<input  type="text" class="span11" name="depton" placeholder="">		
										<span class="error_msg" name="error_depton"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">数据创建日期 :</label>																									
									<div class="controls">																																
										<input  type="date" class="span11" name="createData" placeholder="">		
										<span class="error_msg" name="error_createData"></span> 																						
									</div>																																					
								</div>																																						
								<div class="control-group">																																
									<label class="control-label">数据修改日期 :</label>																									
									<div class="controls">																																
										<input  type="date" class="span11" name="updateDate" placeholder="">		
										<span class="error_msg" name="error_updateDate"></span> 																						
									</div>																																					
								</div>																																						
								<div class="form-actions">																																	
									<button type="button" class="btn btn-success f-right" style="float:right" onclick="save()">保存</button>												
								</div>																																							
							</form>																																								
						</div>																																									
					</div>																																										
				</div>																																											
			</div>																																												
		</div>																																													
	</div>																																														
	<script>																																													
	    var params = C.getParams("${param}");   //接收传来的参数																																							
	    var _pageNum = "" ;  //接收list页面传来的当面页数																																				
		//初始化表单数据																																												
		$(document).ready(function(){																																							
			_pageNum = "${param.pageNum}" ;																																					
			if(!$.isEmptyObject(params)){																																						
				$("input[primaryKey='true']").attr("readonly","readonly");																												
				$.ajax({																																										
					url:"<%=path%>/employee/get",																																			
				    data:params,																																						
				    type:"post",																																								
				    success:function(text){																																						
				    	if(text.success){																																						
				    		$("#employeeForm").autofill(text.data);																															
				    	}																																										
				    }																																											
				});																																												
			}																																													
		});																																														
		//保存表单数据																																												
		function save(){																																										
			var _editType = null ;																																								
			if(!$.isEmptyObject(params)){																																						
				_editType = "edit";																																							
				$("#employeeForm").prop("action","<%=path %>/employee/update");																					
			}else{																																												
				_editType = "add";																																							
				$("#employeeForm").prop("action","<%=path %>/employee/add");																						
			}																																													
			//保存																																												
			$("#employeeForm").ajaxSubmit(function(text){																															
			    C.showMsg(text.message);
			    if(text.success){																																								
			    	if(_editType == "edit"){																																					
			    		window.history.go(-1); //返回原页面																																			
			    	}else if(_editType == "add"){																																				
						$("#employeeForm").prop("action","<%=path %>/employee/detail");																											
						$("#employeeForm").submit();																																				
			    	}																																											
				}																																												
			});																																													
		}																																														
	</script>																																													
</body>																																														
 </html>	    																																												

